﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using BussinessLayer;

namespace projectQLDV
{
    public partial class frmDiemThuongPhat : DevExpress.XtraEditors.XtraForm
    {
        private string[] idDV;
        private frmMain frmM;
        private string namhoc;
        public frmDiemThuongPhat(frmMain frm, string[] id, string nh)
        {
            InitializeComponent();
            frmM = frm;
            idDV = id;
            namhoc = nh;
            this.labelNamHoc.Text = "Năm học: " + namhoc;
        }

        private void btnLuu_Click(object sender, EventArgs e)
        {
            if (this.textEditDiem.Text == "")
            {
                DevExpress.XtraEditors.XtraMessageBox.Show("Xin nhập đầy đủ dữ liệu", "Thông báo");
            }
            else
            {
                int hocky = 1;
                if (!this.checkEditHocKy1.Checked)
                    hocky = 2;
                int diem = int.Parse(this.textEditDiem.Text);
                bool thuong = this.checkEditDiemThuong.Checked;
                string lydo = this.textLyDo.Text;
                try
                {
                    tblDoanvien_thuongphat tp = new tblDoanvien_thuongphat();
                    foreach (string id in idDV)
                    {
                        tp.Insert(int.Parse(id), hocky, namhoc, diem, thuong, lydo);
                    }
                    DevExpress.XtraEditors.XtraMessageBox.Show("Lưu thành công !!!");
                }
                catch (Exception ex)
                {
                    DevExpress.XtraEditors.XtraMessageBox.Show("Error: " + ex);
                }
            }
        }

        private void btnThoat_Click(object sender, EventArgs e)
        {
            this.Close();
            this.Dispose();
        }

        private void frmDiemThuongPhat_FormClosed(object sender, FormClosedEventArgs e)
        {
            frmM.frmThuongPhat_isShown = false;
        }
    }
}